//
//  JYBaseViewController.swift
//  JYCalculate
//
//  Created by 何治军 on 2018/10/26.
//  Copyright © 2018 何治军. All rights reserved.
//

import UIKit

class JYBaseViewController: UIViewController {
    
    var hiddenLeftBtn = false {
        didSet{
            self.navigationItem.leftBarButtonItem = hiddenLeftBtn ? nil : self.leftBtn
        }
    }
    
    func setUpUI(){
    }
    
    func setDefaultInfo(){
    }
    
    func setTheLayout(){
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.edgesForExtendedLayout = UIRectEdge(rawValue: 0)
        self.view.backgroundColor = JYVCBackGroundColor
        self.leftBtn.image = UIImage(named: "nav_back_blue")
        self.hiddenLeftBtn = false
        setUpUI()
        setDefaultInfo()
        setTheLayout()
    }
    
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        self.navigationController?.navigationBar.barTintColor = JYVCBackGroundColor
        self.navigationController?.navigationBar.titleTextAttributes = [NSAttributedString.Key.font:UIFont.systemFont(ofSize: 20),NSAttributedString.Key.foregroundColor:JYNavigationBarColor]
    }
    
    
    @objc func clickLeftBtn(){
        self.navigationController?.popViewController(animated: true)
    }
    
    lazy var leftBtn :UIBarButtonItem = {
        let btn = UIBarButtonItem.init(title: "", style: .plain, target: self, action: #selector(clickLeftBtn))
        btn.tintColor = JYNavigationBarColor
        return btn;
    }()
    

}
